<!DOCTYPE html>
<html lang="zh-cn" dir="ltr">
    <head><meta charset='utf-8'>
<meta name='viewport' content='width=device-width, initial-scale=1'><meta name='description' content='官网 https://www.msys2.org/ 换源 1 sed -i &amp;#34;s#https\?://mirror.msys2.org/#https://mirrors.tuna.tsinghua.edu.cn/msys2/#g&amp;#34; /etc/pacman.d/mirrorlist* 清华源帮助：https://mirror.tuna.tsinghua.edu.cn/help/msys2/ MSYS2中M'>
<title>MSYS2</title>

<link rel='canonical' href='https://ypr.gitee.io/p/prog/msys2/'>

<link rel="stylesheet" href="/scss/style.min.abbd69b2908fdfcd5179898beaafd374514a86538d81639ddd2c58c06ae54e40.css"><meta property='og:title' content='MSYS2'>
<meta property='og:description' content='官网 https://www.msys2.org/ 换源 1 sed -i &amp;#34;s#https\?://mirror.msys2.org/#https://mirrors.tuna.tsinghua.edu.cn/msys2/#g&amp;#34; /etc/pacman.d/mirrorlist* 清华源帮助：https://mirror.tuna.tsinghua.edu.cn/help/msys2/ MSYS2中M'>
<meta property='og:url' content='https://ypr.gitee.io/p/prog/msys2/'>
<meta property='og:site_name' content='天远博客'>
<meta property='og:type' content='article'><meta property='article:section' content='Post' /><meta property='article:tag' content='编程' /><meta property='article:tag' content='MSYS2' /><meta property='article:published_time' content='2023-11-24T13:00:21&#43;08:00'/><meta property='article:modified_time' content='2023-11-28T14:00:21&#43;08:00'/>
<meta name="twitter:title" content="MSYS2">
<meta name="twitter:description" content="官网 https://www.msys2.org/ 换源 1 sed -i &amp;#34;s#https\?://mirror.msys2.org/#https://mirrors.tuna.tsinghua.edu.cn/msys2/#g&amp;#34; /etc/pacman.d/mirrorlist* 清华源帮助：https://mirror.tuna.tsinghua.edu.cn/help/msys2/ MSYS2中M">
    </head>
    <body class="
    article-page
    ">
    <script>
        (function() {
            const colorSchemeKey = 'StackColorScheme';
            if(!localStorage.getItem(colorSchemeKey)){
                localStorage.setItem(colorSchemeKey, "auto");
            }
        })();
    </script><script>
    (function() {
        const colorSchemeKey = 'StackColorScheme';
        const colorSchemeItem = localStorage.getItem(colorSchemeKey);
        const supportDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches === true;

        if (colorSchemeItem == 'dark' || colorSchemeItem === 'auto' && supportDarkMode) {
            

            document.documentElement.dataset.scheme = 'dark';
        } else {
            document.documentElement.dataset.scheme = 'light';
        }
    })();
</script>
<div class="container main-container flex on-phone--column extended"><aside class="sidebar left-sidebar sticky ">
    <button class="hamburger hamburger--spin" type="button" id="toggle-menu" aria-label="切换菜单">
        <span class="hamburger-box">
            <span class="hamburger-inner"></span>
        </span>
    </button>

    <header>
        
            
            <figure class="site-avatar">
                <a href="/">
                
                    
                    
                    
                        
                        <img src="/img/TianYuan_hu00d35ae089bda3bce539f572b00404d0_57842_300x0_resize_box_3.png" width="300"
                            height="300" class="site-logo" loading="lazy" alt="Avatar">
                    
                
                </a>
                
            </figure>
            
        
        
        <div class="site-meta">
            <h1 class="site-name"><a href="/">天远博客</a></h1>
            <h2 class="site-description">专注于技术沉淀！！！</h2>
        </div>
    </header><ol class="social-menu">
            
                <li>
                    <a 
                        href='https://github.com/yuanpeirong'
                        target="_blank"
                        title="GitHub"
                        rel="me"
                    >
                        
                        
                            <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-brand-github" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  <path stroke="none" d="M0 0h24v24H0z" fill="none"/>
  <path d="M9 19c-4.3 1.4 -4.3 -2.5 -6 -3m12 5v-3.5c0 -1 .1 -1.4 -.5 -2c2.8 -.3 5.5 -1.4 5.5 -6a4.6 4.6 0 0 0 -1.3 -3.2a4.2 4.2 0 0 0 -.1 -3.2s-1.1 -.3 -3.5 1.3a12.3 12.3 0 0 0 -6.2 0c-2.4 -1.6 -3.5 -1.3 -3.5 -1.3a4.2 4.2 0 0 0 -.1 3.2a4.6 4.6 0 0 0 -1.3 3.2c0 4.6 2.7 5.7 5.5 6c-.6 .6 -.6 1.2 -.5 2v3.5" />
</svg>



                        
                    </a>
                </li>
            
                <li>
                    <a 
                        href='http://www.yprnet.com'
                        target="_blank"
                        title="天远网站"
                        rel="me"
                    >
                        
                        
                            <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-home" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  <path stroke="none" d="M0 0h24v24H0z"/>
  <polyline points="5 12 3 12 12 3 21 12 19 12" />
  <path d="M5 12v7a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-7" />
  <path d="M9 21v-6a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v6" />
</svg>



                        
                    </a>
                </li>
            
        </ol><ol class="menu" id="main-menu">
        
        
        
        <li >
            <a href='/' >
                
                
                
                    <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-home" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  <path stroke="none" d="M0 0h24v24H0z"/>
  <polyline points="5 12 3 12 12 3 21 12 19 12" />
  <path d="M5 12v7a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-7" />
  <path d="M9 21v-6a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v6" />
</svg>



                
                <span>主页</span>
            </a>
        </li>
        
        
        <li >
            <a href='/about/' >
                
                
                
                    <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-user" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  <path stroke="none" d="M0 0h24v24H0z"/>
  <circle cx="12" cy="7" r="4" />
  <path d="M6 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2" />
</svg>



                
                <span>关于</span>
            </a>
        </li>
        
        
        <li >
            <a href='/archives/' >
                
                
                
                    <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-archive" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  <path stroke="none" d="M0 0h24v24H0z"/>
  <rect x="3" y="4" width="18" height="4" rx="2" />
  <path d="M5 8v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-10" />
  <line x1="10" y1="12" x2="14" y2="12" />
</svg>



                
                <span>归档</span>
            </a>
        </li>
        
        
        <li >
            <a href='/search/' >
                
                
                
                    <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-search" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  <path stroke="none" d="M0 0h24v24H0z"/>
  <circle cx="10" cy="10" r="7" />
  <line x1="21" y1="21" x2="15" y2="15" />
</svg>



                
                <span>搜索</span>
            </a>
        </li>
        
        
        <li >
            <a href='/links/' >
                
                
                
                    <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  <path stroke="none" d="M0 0h24v24H0z"/>
  <path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5" />
  <path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5" />
</svg>



                
                <span>链接</span>
            </a>
        </li>
        

        <div class="menu-bottom-section">
            
            
                <li id="dark-mode-toggle">
                    <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-toggle-left" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  <path stroke="none" d="M0 0h24v24H0z"/>
  <circle cx="8" cy="12" r="2" />
  <rect x="2" y="6" width="20" height="12" rx="6" />
</svg>



                    <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-toggle-right" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  <path stroke="none" d="M0 0h24v24H0z"/>
  <circle cx="16" cy="12" r="2" />
  <rect x="2" y="6" width="20" height="12" rx="6" />
</svg>



                    <span>暗色模式</span>
                </li>
            
        </div>
    </ol>
</aside>

    <aside class="sidebar right-sidebar sticky">
        
            
                
    <section class="widget archives">
        <div class="widget-icon">
            <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-hash" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  <path stroke="none" d="M0 0h24v24H0z"/>
  <line x1="5" y1="9" x2="19" y2="9" />
  <line x1="5" y1="15" x2="19" y2="15" />
  <line x1="11" y1="4" x2="7" y2="20" />
  <line x1="17" y1="4" x2="13" y2="20" />
</svg>



        </div>
        <h2 class="widget-title section-title">目录</h2>
        
        <div class="widget--toc">
            <nav id="TableOfContents">
  <ol>
    <li><a href="#官网">官网</a></li>
    <li><a href="#换源">换源</a></li>
    <li><a href="#msys2中mingw_package_prefix对应关系">MSYS2中MINGW_PACKAGE_PREFIX对应关系</a></li>
    <li><a href="#安装记录">安装记录</a>
      <ol>
        <li><a href="#安装工具链">安装工具链</a></li>
        <li><a href="#安装qt5库">安装Qt5库</a></li>
        <li><a href="#安装qt6库">安装Qt6库</a></li>
        <li><a href="#仅安装编译工具">仅安装编译工具</a></li>
        <li><a href="#安装make">安装make</a></li>
        <li><a href="#安装gdb">安装GDB</a></li>
        <li><a href="#仅msys2环境下的工具安装">仅MSYS2环境下的工具安装</a></li>
        <li><a href="#安装其他">安装其他</a></li>
        <li><a href="#备注">备注</a></li>
      </ol>
    </li>
    <li><a href="#更新和维护msys2">更新和维护MSYS2</a></li>
    <li><a href="#其他命令参考">其他命令参考</a>
      <ol>
        <li><a href="#1-安装软件">1. 安装软件</a></li>
        <li><a href="#2-更新系统">2. 更新系统</a></li>
        <li><a href="#3-卸载软件">3. 卸载软件</a></li>
        <li><a href="#4-搜索软件">4. 搜索软件</a></li>
        <li><a href="#5-软件包组">5. 软件包组</a></li>
        <li><a href="#6-清除缓存">6. 清除缓存</a></li>
      </ol>
    </li>
  </ol>
</nav>
        </div>
    </section>

            
        
    </aside>


            <main class="main full-width">
    <article class="main-article">
    <header class="article-header">

    <div class="article-details">
    
    <header class="article-category">
        
            <a href="/categories/%E7%BC%96%E7%A8%8B/" >
                编程
            </a>
        
            <a href="/categories/msys2/" >
                MSYS2
            </a>
        
    </header>
    

    <div class="article-title-wrapper">
        <h2 class="article-title">
            <a href="/p/prog/msys2/">MSYS2</a>
        </h2>
    
        
    </div>

    
        <footer class="article-time">
            
                <div>
                    <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-calendar-time" width="56" height="56" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  <path stroke="none" d="M0 0h24v24H0z"/>
  <path d="M11.795 21h-6.795a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v4" />
  <circle cx="18" cy="18" r="4" />
  <path d="M15 3v4" />
  <path d="M7 3v4" />
  <path d="M3 11h16" />
  <path d="M18 16.496v1.504l1 1" />
</svg>
                    <time class="article-time--published">2023-11-24</time>
                </div>
            

            
            
                        最后更新:
                        <time class="article-time--updated" datetime="2023-11-28 14:00:21 &#43;0800 CST" title="2023-11-28 14:00:21 &#43;0800 CST">
                            2023-11-28
                        </time>

            
                <div>
                    <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-clock" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  <path stroke="none" d="M0 0h24v24H0z"/>
  <circle cx="12" cy="12" r="9" />
  <polyline points="12 7 12 12 15 15" />
</svg>



                    <time class="article-time--reading">
                        阅读时长: 4 分钟
                    </time>
                </div>
            
        </footer>
    


    
</div>

</header>

    <section class="article-content">
    
    
    <h2 id="官网">官网</h2>
<ul>
<li><a class="link" href="https://www.msys2.org/"  target="_blank" rel="noopener"
    >https://www.msys2.org/</a></li>
</ul>
<h2 id="换源">换源</h2>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sed -i <span class="s2">&#34;s#https\?://mirror.msys2.org/#https://mirrors.tuna.tsinghua.edu.cn/msys2/#g&#34;</span> /etc/pacman.d/mirrorlist*
</span></span></code></pre></td></tr></table>
</div>
</div><ul>
<li>清华源帮助：<a class="link" href="https://mirror.tuna.tsinghua.edu.cn/help/msys2/"  target="_blank" rel="noopener"
    >https://mirror.tuna.tsinghua.edu.cn/help/msys2/</a></li>
</ul>
<h2 id="msys2中mingw_package_prefix对应关系">MSYS2中MINGW_PACKAGE_PREFIX对应关系</h2>
<ul>
<li>参考：<a class="link" href="https://www.msys2.org/docs/package-naming/"  target="_blank" rel="noopener"
    >https://www.msys2.org/docs/package-naming/</a></li>
<li>参考：<a class="link" href="https://www.msys2.org/docs/environments/"  target="_blank" rel="noopener"
    >https://www.msys2.org/docs/environments/</a></li>
</ul>
<div class="table-wrapper"><table>
<thead>
<tr>
<th style="text-align:left">Name</th>
<th style="text-align:left">MINGW_PACKAGE_PREFIX</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">MSYS</td>
<td style="text-align:left">None</td>
</tr>
<tr>
<td style="text-align:left">MINGW64</td>
<td style="text-align:left">mingw-w64-x86_64-</td>
</tr>
<tr>
<td style="text-align:left">UCRT64</td>
<td style="text-align:left">mingw-w64-ucrt-x86_64-</td>
</tr>
<tr>
<td style="text-align:left">CLANG64</td>
<td style="text-align:left">mingw-w64-clang-x86_64-</td>
</tr>
<tr>
<td style="text-align:left">MINGW32</td>
<td style="text-align:left">mingw-w64-i686-</td>
</tr>
<tr>
<td style="text-align:left">CLANG32</td>
<td style="text-align:left">mingw-w64-clang-i686-</td>
</tr>
<tr>
<td style="text-align:left">CLANGARM64</td>
<td style="text-align:left">mingw-w64-clang-aarch64-</td>
</tr>
</tbody>
</table></div>
<h2 id="安装记录">安装记录</h2>
<h3 id="安装工具链">安装工具链</h3>
<ul>
<li>pacman -S mingw-w64-x86_64-toolchain</li>
<li>pacman -S mingw-w64-ucrt-x86_64-toolchain</li>
<li>pacman -S mingw-w64-clang-x86_64-toolchain</li>
<li>pacman -S mingw-w64-i686-toolchain</li>
<li>pacman -S mingw-w64-clang-i686-toolchain</li>
<li>pacman -S mingw-w64-clang-aarch64-toolchain</li>
<li>pacman -S $MINGW_PACKAGE_PREFIX-toolchain</li>
</ul>
<h3 id="安装qt5库">安装Qt5库</h3>
<ul>
<li>pacman -S mingw-w64-x86_64-qt5-static</li>
<li>pacman -S mingw-w64-ucrt-x86_64-qt5-static</li>
<li>pacman -S mingw-w64-clang-x86_64-qt5-static</li>
<li>pacman -S mingw-w64-i686-qt5-static</li>
<li>pacman -S mingw-w64-clang-i686-qt5-static</li>
<li>pacman -S mingw-w64-clang-aarch64-qt5-stat</li>
<li>pacman -S $MINGW_PACKAGE_PREFIX-qt5-static</li>
</ul>
<h3 id="安装qt6库">安装Qt6库</h3>
<ul>
<li>pacman -S mingw-w64-ucrt-x86_64-qt6-static</li>
</ul>
<h3 id="仅安装编译工具">仅安装编译工具</h3>
<ul>
<li>pacman -S mingw-w64-ucrt-x86_64-gcc</li>
<li>pacman -S mingw-w64-x86_64-gcc</li>
<li>pacman -S mingw-w64-i686-gcc</li>
<li>pacman -S mingw-w64-clang-x86_64-gcc</li>
<li>pacman -S mingw-w64-clang-i686-gcc</li>
</ul>
<h3 id="安装make">安装make</h3>
<ul>
<li>pacman -S mingw-w64-ucrt-x86_64-make</li>
<li>pacman -S mingw-w64-clang-x86_64-make</li>
</ul>
<h3 id="安装gdb">安装GDB</h3>
<ul>
<li>pacman -S mingw-w64-ucrt-x86_64-gdb</li>
<li>pacman -S mingw-w64-clang-x86_64-lldb</li>
</ul>
<h3 id="仅msys2环境下的工具安装">仅MSYS2环境下的工具安装</h3>
<p>pacman -S binutils      //二进制工具集           <br>
pacman -S gcc           //GNU编译器集合-C和C++前端<br>
pacman -S gcc-libs      //GCC提供的运行时库
pacman -S gdb           //GNU调试器              <br>
pacman -S gettext       //GNU国际化库            <br>
pacman -S gettext-devel //GNU国际化开发实用程序  <br>
pacman -S make          //make工具</p>
<h3 id="安装其他">安装其他</h3>
<ul>
<li>pacman -S base        //Minimal package set to define a basic MSYS2 installation</li>
<li>pacman -S base-devel  //Minimal package set for building packages with makepkg</li>
<li>pacman -S vim</li>
<li>pacman -S yasm</li>
<li>pacman -S nasm</li>
</ul>
<h3 id="备注">备注</h3>
<p>MSYS2中有两种工具链：</p>
<ul>
<li>一种是原生GCC，其编译的是UNIX代码，运行依赖msys2xxx.dll；</li>
<li>一种是mingw工具链，用于编译windows代码（能调用windows API，不能调用unix系统调用）的，
生成exe，运行时只依赖windows系统的dll。</li>
</ul>
<h2 id="更新和维护msys2">更新和维护MSYS2</h2>
<ul>
<li>参考：<a class="link" href="https://www.msys2.org/docs/updating/"  target="_blank" rel="noopener"
    >https://www.msys2.org/docs/updating/</a></li>
</ul>
<p>通过安装程序或其他方式安装 MSYS2 后，您需要继续使用内置工具对其进行更新。MSYS2 是一个滚动发布发行版，仅支持完整的系统升级，这意味着各种软件包经常进行次要和主要更新，并且您只能一次更新所有软件包。
若要更新所有包，请运行以下命令：</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt"> 1
</span><span class="lnt"> 2
</span><span class="lnt"> 3
</span><span class="lnt"> 4
</span><span class="lnt"> 5
</span><span class="lnt"> 6
</span><span class="lnt"> 7
</span><span class="lnt"> 8
</span><span class="lnt"> 9
</span><span class="lnt">10
</span><span class="lnt">11
</span><span class="lnt">12
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">$ pacman -Suy
</span></span><span class="line"><span class="cl">:: Synchronizing package databases...
</span></span><span class="line"><span class="cl"> mingw32 is up to date
</span></span><span class="line"><span class="cl"> mingw64 is up to date
</span></span><span class="line"><span class="cl"> ucrt64 is up to date
</span></span><span class="line"><span class="cl"> clang32 is up to date
</span></span><span class="line"><span class="cl"> clang64 is up to date
</span></span><span class="line"><span class="cl"> msys is up to date
</span></span><span class="line"><span class="cl">:: Starting core system upgrade...
</span></span><span class="line"><span class="cl"> there is nothing to <span class="k">do</span>
</span></span><span class="line"><span class="cl">:: Starting full system upgrade...
</span></span><span class="line"><span class="cl"> there is nothing to <span class="k">do</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>在某些情况下，某些核心软件包会被更新，pacman 会提示你关闭所有终端：</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">:: To <span class="nb">complete</span> this update all MSYS2 processes including this terminal will be closed.
</span></span><span class="line"><span class="cl">   Confirm to proceed <span class="o">[</span>Y/n<span class="o">]</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>确认后，您需要启动一个新终端并再次运行更新，以更新剩余的非核心包。<code>pacman -Suy</code></p>
<h2 id="其他命令参考">其他命令参考</h2>
<h3 id="1-安装软件">1. 安装软件</h3>
<ul>
<li>pacman -S 软件名: 安装软件。也可以同时安装多个包，只需以空格分隔包名即可。</li>
<li>pacman -S &ndash;needed 软件名1 软件名2: 安装软件，但不重新安装已经是最新的软件。</li>
<li>pacman -Sy 软件名：安装软件前，先从远程仓库下载软件包数据库(数据库即所有软件列表)。</li>
<li>pacman -Sv 软件名：在显示一些操作信息后执行安装。</li>
<li>pacman -Sw 软件名: 只下载软件包，不安装。</li>
<li>pacman -U 软件名.pkg.tar.gz：安装本地软件包。</li>
<li>pacman -U <a class="link" href="http://www.example.com/repo/example.pkg.tar.xz"  target="_blank" rel="noopener"
    >http://www.example.com/repo/example.pkg.tar.xz</a> : 安装一个远程包（不在 pacman 配置的源里面）。</li>
</ul>
<h3 id="2-更新系统">2. 更新系统</h3>
<ul>
<li>pacman -Sy: 从服务器下载新的软件包数据库（实际上就是下载远程仓库最新软件列表到本地）。</li>
<li>pacman -Su: 升级所有已安装的软件包。</li>
</ul>
<h3 id="3-卸载软件">3. 卸载软件</h3>
<ul>
<li>pacman -R 软件名: 该命令将只删除包，保留其全部已经安装的依赖关系</li>
<li>pacman -Rv 软件名: 删除软件，并显示详细的信息</li>
<li>pacman -Rs 软件名: 删除软件，同时删除本机上只有该软件依赖的软件。</li>
<li>pacman -Rsc 软件名: 删除软件，并删除所有依赖这个软件的程序，慎用</li>
<li>pacman -Ru 软件名: 删除软件,同时删除不再被任何软件所需要的依赖</li>
</ul>
<h3 id="4-搜索软件">4. 搜索软件</h3>
<ul>
<li>pacman -Ss 关键字: 在仓库中搜索含关键字的软件包（本地已安装的会标记）</li>
<li>pacman -Sl <repo>:显示软件仓库中所有软件的列表。可以省略，通常这样用:<code>pacman -Sl | 关键字</code></li>
<li>pacman -Qs 关键字: 搜索已安装的软件包</li>
<li>pacman -Qu: 列出所有可升级的软件包</li>
<li>pacman -Qt: 列出不被任何软件要求的软件包</li>
</ul>
<p>查看软件信息</p>
<ul>
<li>pacman -Q 软件名: 查看软件包是否已安装，已安装则显示软件包名称和版本</li>
<li>pacman -Qi 软件名: 查看某个软件包信息，显示较为详细的信息，包括描述、构架、依赖、大小等等</li>
<li>pacman -Ql 软件名: 列出软件包内所有文件，包括软件安装的每个文件、文件夹的名称和路径</li>
</ul>
<h3 id="5-软件包组">5. 软件包组</h3>
<p>pacman -Sg: 列出软件仓库上所有的软件包组
pacman -Qg: 列出本地已经安装的软件包组和子包
pacman -Sg 软件包组: 查看某软件包组所包含的所有软件包
pacman -Qg 软件包组: 和pacman -Sg 软件包组完全一样</p>
<h3 id="6-清除缓存">6. 清除缓存</h3>
<ul>
<li>
<p>pacman -Sc：清理未安装的包文件，包文件位于 /var/cache/pacman/pkg/ 目录。</p>
</li>
<li>
<p>pacman -Scc：清理所有的缓存文件。</p>
<p>pacman 安装包缓存位置及清理<br>
如果进行系统更新时,磁盘不足,清理软件安装包缓存是一种可行的方案.<br>
pacman 会将自己下载的软件压缩包保存在 /var/cache/pacman/pkg/目录下,<br>
默认情况下并不会删除安装包,即便软件已经卸载.<br>
下面提供几个清理程度不同的命令.</p>
</li>
<li>
<p>paccache -r # 清理缓存,仅包含最近的三个版本</p>
</li>
<li>
<p>paccache -rk1 # 清理缓存,仅包含最近的1个版本</p>
</li>
<li>
<p>pacman -Sc # 清理未安装软件包</p>
</li>
<li>
<p>pacman -Scc # 清理缓存中所有内容</p>
</li>
</ul>

</section>


    <footer class="article-footer">
    
    <section class="article-tags">
        
            <a href="/tags/%E7%BC%96%E7%A8%8B/">编程</a>
        
            <a href="/tags/msys2/">MSYS2</a>
        
    </section>
<section class="article-lastmod">
        <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-clock" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  <path stroke="none" d="M0 0h24v24H0z"/>
  <circle cx="12" cy="12" r="9" />
  <polyline points="12 7 12 12 15 15" />
</svg>



        <span>
            最后更新于 2023-11-28 14:00 CST
        </span>
    </section></footer>
<footer class="article-footer">
    
    <section class="article-copyright">
        <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-copyright" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  <path stroke="none" d="M0 0h24v24H0z"/>
  <circle cx="12" cy="12" r="9" />
  <path d="M14.5 9a3.5 4 0 1 0 0 6" />
</svg>



        
		<span>版权声明：本文遵循&ensp;&ensp;<a href="https://creativecommons.org/licenses/by-nc-nd/4.0/deed.zh-hans" target="_blank" rel="noopener">CC BY-NC-ND 4.0 DEED (署名-非商业性使用-禁止演绎4.0国际)</a>&ensp;&ensp;版权协议。</span>
	</section>	
    
</footer>
<footer class="article-footer">
    
    <section class="article-copyright">
        <span>&ensp;&ensp;&ensp;&ensp;&ensp;转载说明：请附上本文链接及上述版权声明。</span>
	</section>	
    
</footer>


    
</article>

    

    

<aside class="related-content--wrapper">
    <h2 class="section-title">相关文章</h2>
    <div class="related-content">
        <div class="flex article-list--tile">
            
                
<article class="">
    <a href="/p/prog/msys2-gcc-locale/">
        
        

        <div class="article-details">
            <h2 class="article-title">MSYS2中的GCC本地化</h2>
        </div>
    </a>
</article>

            
                
<article class="">
    <a href="/p/prog/cpp-gcc-sharedandstaticlib/">
        
        

        <div class="article-details">
            <h2 class="article-title">GCC上的动态库与静态库</h2>
        </div>
    </a>
</article>

            
                
<article class="">
    <a href="/p/prog/cpp-gcc-locale-windows-mingw64/">
        
        

        <div class="article-details">
            <h2 class="article-title">MinGW-w64 GCC本地化-Windows</h2>
        </div>
    </a>
</article>

            
                
<article class="">
    <a href="/p/prog/cpp-gcc-locale-linux/">
        
        

        <div class="article-details">
            <h2 class="article-title">GCC本地化-Linux</h2>
        </div>
    </a>
</article>

            
                
<article class="">
    <a href="/p/prog/cpp-gcc-env-var/">
        
        

        <div class="article-details">
            <h2 class="article-title">GCC环境变量</h2>
        </div>
    </a>
</article>

            
        </div>
    </div>
</aside>

     
    
        
    

    <footer class="site-footer">
    
	<section class="copyright">
	    技术交流： <a href="mailto:ypr@yprnet.com" target="_blank" rel="noopener">ypr@yprnet.com</a>、
		<a href="mailto:ypr@yuanpeirong.com" target="_blank" rel="noopener">ypr@yuanpeirong.com</a>
		<br />版权所有 © 2010-2025 <a title="访问天远网站" href="http://www.yprnet.com/" target="_blank" rel="noopener">YuanPeirong TianYuan</a> All Rights Reserved. Powered By <a title="访问天远网站" href="http://www.yprnet.com/" target="_blank" rel="noopener">天远</a>
    </section>
    <section class="powerby">
        Built with <a href="https://gohugo.io/" target="_blank" rel="noopener">Hugo</a> <br />
        主题 <b><a href="https://github.com/CaiJimmy/hugo-theme-stack" target="_blank" rel="noopener" data-version="3.21.0">Stack</a></b> 由 <a href="https://jimmycai.com" target="_blank" rel="noopener">Jimmy</a> 设计 | <a href="http://www.yprnet.com/" target="_blank" rel="noopener">天远</a> 优化修改
    </section>
    <section class="powerby">
        <a target="_blank" href="https://beian.miit.gov.cn">浙ICP备15010776号-3</a>
    </section>
</footer>


    
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    
    <div class="pswp__bg"></div>

    
    <div class="pswp__scroll-wrap">

        
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                
                
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div><script 
                src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"integrity="sha256-ePwmChbbvXbsO02lbM3HoHbSHTHFAeChekF1xKJdleo="crossorigin="anonymous"
                defer
                >
            </script><script 
                src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"integrity="sha256-UKkzOn/w1mBxRmLLGrSeyB4e1xbrp4xylgAWb3M42pU="crossorigin="anonymous"
                defer
                >
            </script><link 
                rel="stylesheet" 
                href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.min.css"crossorigin="anonymous"
            ><link 
                rel="stylesheet" 
                href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css"crossorigin="anonymous"
            >

            </main>
        </div>
        <script 
                src="https://cdn.jsdelivr.net/npm/node-vibrant@3.1.6/dist/vibrant.min.js"integrity="sha256-awcR2jno4kI5X0zL8ex0vi2z&#43;KMkF24hUW8WePSA9HM="crossorigin="anonymous"
                
                >
            </script><script type="text/javascript" src="/ts/main.js" defer></script>
<script>
    (function () {
        const customFont = document.createElement('link');
        customFont.href = "https://fonts.googleapis.com/css2?family=Lato:wght@300;400;700&display=swap";

        customFont.type = "text/css";
        customFont.rel = "stylesheet";

        document.head.appendChild(customFont);
    }());
</script>

    </body>
</html>
